package cn.kgc.tangcco.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 李昊哲
 * @Description
 * @create 2021/1/26 9:47
 */
@RestController
public class SessionShareController {
    @GetMapping(value = "/set")
    public String set(HttpSession session) {
        session.setAttribute("slogan", "love love love");
        return "OK";
    }

    @GetMapping(value = "/get")
    public Map<String, Object> get(HttpSession session) {
        Map<String, Object> map = new HashMap<>();
        map.put("sessionId", session.getId());
        map.put("slogan", session.getAttribute("slogan"));
        return map;
    }

}
